<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/react.development.js"></script>
    <script src="../js/react-dom.development.js"></script>
    <script src="../js/babel.min.js"></script>
    <script src="../js/prop-types.js"></script>
</head>
<body>
    <div id="root"></div>
    <script type="text/babel">
        function HideComponent(props) {
            if (props.hide)
                return null;
            return <div>this.props.hide = {props.hide.toString()}</div>
        }
        class Welcome extends React.Component {
            constructor(props) {
                super(props);
                this.state = {
                    hide: true,
                }
            }
            changeState = () => {
                this.setState((prevState) => ({hide: !prevState.hide}))
                console.log(this.state.hide);
            }
            render() {
                return (
                    <div>
                        <HideComponent hide={this.state.hide}/>
                        <button onClick={this.changeState}>
                            {this.state.hide ? 'show' : 'hide'}
                        </button>
                    </div>
                )
            }
        }
        ReactDOM.render(<Welcome/>, document.getElementById('root'));
    </script>
</body>
</html>